﻿package com.game.module.semiInterface
{
	import com.dusk.util.TextUtil;
	import com.game.data.constant.ConfigConst;
	import com.game.event.GameEvent;
	import com.game.manager.NotificationManager;
	
	import config.Config;
	
	import flash.display.MovieClip;
	import flash.display.SimpleButton;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	
	public class ToThePast extends Sprite
	{
		
		public function ToThePast()
		{
			super();
			TextUtil.redrawTxtOld(this, ["timetxt", "saytxt"]);
			this.gc = Config.getIns();
			this.nmwmc.buttonMode = true;
			this.zlwmc.buttonMode = true;
			this.qlmc.buttonMode = true;
			this.addEventListener(Event.ADDED_TO_STAGE, this.added, false, 0, true);
			this.addEventListener(Event.REMOVED_FROM_STAGE, this.removed, false, 0, true);
		}
		
		public var throughbtn:SimpleButton;
		public var xbtn:SimpleButton;
		public var nmwmc:MovieClip;
		public var zlwmc:MovieClip;
		public var qlmc:MovieClip;
		public var timetxt:TextField;
		public var saytxt:TextField;
		private var gc:Config;
		private var tid:String = "";
		
		private function setTxt():void
		{
			this.timetxt.text = "无限";
			this.saytxt.text = this.findIntroduceByTid(this.tid);
		}
		
		private function findIntroduceByTid(param1:String):String
		{
			if (param1 == "nmwmc")
			{
				return "通过混沌之门穿越回到造1时代的牛魔谷，与昔日的弟兄们对峙，同时从被黑白无常救下的牛魔王手中夺取通天令牌碎片";
			}
			if (param1 == "zlwmc")
			{
				return "通过混沌之门穿越到造2时代的地府，与一众阴司周旋，并夺取转轮王手中的通天令牌碎片";
			}
			if (param1 == "qlmc")
			{
				return "通过混沌之门穿越回到饕餮刚吞噬青龙时候的青龙之森。击败饕餮，拯救神兽青龙。倘若遇到黑化的二郎神一定要让他交出通天令牌碎片";
			}
			return "搜遍了整个天庭，都找不到玉帝。唯一的可能就是玉帝被人挟持，通过混沌之门传送到另一个世界里了。要进入那个世界就必须拥有通天令牌，而通天令牌却散失在了三界";
		}
		
		private function added(param1:Event):void
		{
			this.throughbtn.addEventListener(MouseEvent.CLICK, this.throughClick);
			this.xbtn.addEventListener(MouseEvent.CLICK, this.xClick);
			this.nmwmc.addEventListener(MouseEvent.CLICK, this.mcClick);
			this.zlwmc.addEventListener(MouseEvent.CLICK, this.mcClick);
			this.qlmc.addEventListener(MouseEvent.CLICK, this.mcClick);
			this.setTxt();
		}
		
		private function removed(param1:Event):void
		{
			this.throughbtn.removeEventListener(MouseEvent.CLICK, this.throughClick);
			this.xbtn.removeEventListener(MouseEvent.CLICK, this.xClick);
			this.nmwmc.removeEventListener(MouseEvent.CLICK, this.mcClick);
			this.zlwmc.removeEventListener(MouseEvent.CLICK, this.mcClick);
			this.qlmc.removeEventListener(MouseEvent.CLICK, this.mcClick);
		}
		
		private function mcClick(param1:MouseEvent):void
		{
			this.nmwmc.gotoAndStop(1);
			this.zlwmc.gotoAndStop(1);
			this.qlmc.gotoAndStop(1);
			this.tid = param1.currentTarget.name;
			param1.currentTarget.gotoAndStop(2);
			this.setTxt();
		}
		
		private function throughClick(param1:MouseEvent):void
		{
			if (this.tid == "")
			{
				return;
			}
			if (this.tid == "nmwmc")
			{
				if (ConfigConst.GAME_VERSION_ID < 0.9)
				{
					NotificationManager.alert("暂未开启！");
					return;
				}
				this.gc.curStage = 17;
				this.gc.curLevel = 1;
			}
			else if (this.tid == "zlwmc")
			{
				if (ConfigConst.GAME_VERSION_ID < 0.9)
				{
					NotificationManager.alert("暂未开启！");
					return;
				}
				this.gc.curStage = 17;
				this.gc.curLevel = 2;
			}
			else if (this.tid == "qlmc")
			{
				this.gc.curStage = 17;
				this.gc.curLevel = 3;
			}
			this.gc.eventManager.dispatchEvent(new GameEvent("SelectStageOver"));
			if (this.parent)
			{
				this.parent.removeChild(this);
			}
		}
		
		private function xClick(param1:MouseEvent):void
		{
			if (this.parent)
			{
				this.parent.removeChild(this);
			}
		}
	}
}
